package com.yzk.back.syscate.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.yzk.back.category.server.ISysCateSer;
import com.yzk.back.model.cate.SysCategory;
import com.yzk.back.sysuser.model.SysUser;
import com.yzk.frame.action.BaseActionSupport;
import com.yzk.frame.utils.util.Page;

@Namespace("/syscate")
@Results( { @Result(name = "ok", location = "/ok.jsp") })
public class SyscateAction extends BaseActionSupport<SysCategory> {

	private static final long serialVersionUID = 1L;
	private Long id ;
	private SysCategory entity ;
	private Page<SysCategory> page = new Page<SysCategory>();
	private ISysCateSer sysCateSerImpl ;

	@Override
	public SysCategory getModel() {
		return entity;
	}

	@Override
	public String list() throws Exception {
		page = this.sysCateSerImpl.getByPage(page) ;
		return "ok";
	}

	@Override
	public String input() throws Exception {
		// TODO Auto-generated method stub
		return INPUT;
	}

	@Override
	public String save() throws Exception {
		this.sysCateSerImpl.save(entity) ;
		return "ok";
	}

	@Override
	public String delete() throws Exception {
		this.sysCateSerImpl.delCate(id);
		return "ok";
	}

	@Override
	protected void prepareModel() throws Exception {
		System.out.println("run prepareModel method");
		if(null!=id) {
			entity = this.sysCateSerImpl.findById(id);
		} else {
			entity = new SysCategory();
		}
		
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public SysCategory getEntity() {
		return entity;
	}

	public void setEntity(SysCategory entity) {
		this.entity = entity;
	}

	public Page<SysCategory> getPage() {
		return page;
	}

	public void setPage(Page<SysCategory> page) {
		this.page = page;
	}

	public ISysCateSer getSysCateSerImpl() {
		return sysCateSerImpl;
	}

	@Resource
	public void setSysCateSerImpl(ISysCateSer sysCateSerImpl) {
		this.sysCateSerImpl = sysCateSerImpl;
	}

	
}
